package com.hc.accountservice.mapper;

import com.hc.accountservice.sqlprovider.SelectPayRecordSql;
import com.hc.entity.PayRecord;
import com.hc.entity.Wallet;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.List;

/**
 * @BelongsProject: hc
 * @BelongsPackage: com.hc.accountservice.mapper
 * @Author: WY
 * @CreateTime: 2022-10-19  16:14
 * @Descriprion: 账户mapper
 * @Version: 1.0
 **/
public interface AccountMapper {

    /**
     *条件查询支付记录
     * @param payRecord
     * @return
     */
    @SelectProvider(type = SelectPayRecordSql.class,method = "select")
    @Results(
            {
                    @Result(column = "id",property = "id",id = true),
                    @Result(column = "datetime",property = "dateTime"),
                    @Result(column = "way",property = "way"),
                    @Result(column = "order_id",property = "order",one = @One(select = "com.hc.accountservice.mapper.OrderMapper.findById",fetchType = FetchType.LAZY))
            }
    )
    List<PayRecord> findByPage(PayRecord payRecord);

    /**
     * 余额查询
     * @param id
     * @return
     */
    @Select("select *from hc_wallet")
    Wallet findBalance(int id);
}
